package whf.shop.web;

import whf.framework.entity.AbstractEntity;
import whf.framework.web.struts.WebData;
import whf.framework.web.struts.WebDispatchAction;
import whf.framework.web.struts.WebForward;
import whf.shop.entity.Currency;
import whf.shop.service.CurrencyService;
import whf.shop.utils.ShopUtils;

/**
 * @author wanghaifeng
 * @email king@126.com
 * @modify 2007-01-11
 */
public class CurrencyAction extends WebDispatchAction {
	
	public WebForward resetCurrency(AbstractEntity baseForm, WebData data) throws Exception {
		long currencyId = data.getLongParameter("currencyId", 0);
		if(currencyId > 0){
			CurrencyService service = (CurrencyService)super.getService();
			Currency old = ShopUtils.getCurrentCurrency(data.getSession());
			if(old.getId() != currencyId){
				Currency cur = service.findByPrimaryKey(currencyId);
				ShopUtils.setCurrentCurrency(data.getSession(), cur);
			}
		}
		return data.forward("selectProducts");
	}
}